import numpy as np
import matplotlib.pyplot as plt
import sympy as sp

# 中文显示
plt.rcParams['font.sans-serif'] = ['SimHei', 'DejaVu Sans']
plt.rcParams['axes.unicode_minus'] = False

# 定义函数和数列
x = sp.symbols('x')
n = sp.symbols('n', integer=True)

# 函数f(x) = x*sin(1/x)
f = x * sp.sin(1/x)

# 两个不同的数列趋近于0
x_n1 = 1/n  # 数列1: 1/n
x_n2 = 1/(n**2)  # 数列2: 1/n^2

# 计算数列极限
limit_seq1 = sp.limit(f.subs(x, x_n1), n, sp.oo)
limit_seq2 = sp.limit(f.subs(x, x_n2), n, sp.oo)

# 计算函数极限
limit_func = sp.limit(f, x, 0)

print(f"数列1的极限: {limit_seq1}")
print(f"数列2的极限: {limit_seq2}")
print(f"函数极限: {limit_func}")